import array


pattern_word=['the','of','and','for','has']
pattern_punctuation=[',','.']


text="The   project's   unique   steel   structure   has   earned   the   favor   of   both   artists   and   the   public   alike.   Time   Magazine   took   it   as   one   of   the   ten   architectural   marvels   for   2007. "


def endWithAnyPunc(str):
    global pattern_punctuation        
    for s in pattern_punctuation:
        if str.lower().endswith(s):
            return True
    return False



def main():
    global text
    words=text.split()
    result=[]
    str=''
    for word in words:
        if (word.lower() in pattern_word) :
            if len(str)!=0:
                result.append(str)
            str=word
        elif (len(words)>1 and endWithAnyPunc(word)):
            str +=' '+word
            result.append(str)
            str=''
        else:
            str +=' '+word
    if len(str)!=0:
        result.append(str)
    
    for s in result :
        print '[',s,']',' ', 
    print
    
if __name__=='__main__':
    main()
